package commands;

import java.util.Iterator;
import java.util.Vector;
import java.util.Map; // Superclass of HashMap

import containers.NewLoanContainer;

import entities.Student;

/**
 * Gets all the students in the new loan container
 * 
 * @author eks691
 * 
 */
public class CheckNewLoan {

	/**
	 * Field holding all the new loans from the NewLoanContainer dictionary
	 */
	private Vector<Student> newLoans;

	public CheckNewLoan() {
		newLoans = new Vector<Student>();
	}

	public Vector<Student> getNewLoans() {
		Map<Integer, Student> map = NewLoanContainer.dictionary();

		for (Student value : map.values()) {
			newLoans.add(value);
			// System.out.println(value.getName());
		}

		return newLoans;
	}

	/**
	 * regression tests
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		CheckNewLoan cnl = new CheckNewLoan();

		Vector<Student> newLoans = cnl.getNewLoans();

		// get an Iterator object for Vector using iterator() method.
		Iterator<Student> itr = newLoans.iterator();

		// use hasNext() and next() methods of Iterator to iterate through the
		// elements
		System.out.println("Iterating through Vector elements...");

		while (itr.hasNext())
			System.out.println(itr.next().getName());

	}
}
